<? 
	ob_start(); 
	require("admin/connect.php");
	$mal=$_REQUEST["lopid"];
	$mamh=$_REQUEST["mhid"];
	$magv=$_REQUEST["gvid"];
	$kyhoc=$_REQUEST["kyhoc"];
	$loaidiem=$_REQUEST["loaidiem"];	
	$ngay=$_REQUEST["demol1"];
	$sqldate = strtotime($ngay);
	$date = date('Y-m-d', $sqldate);	
	$result=mysql_query("select * from hocsinh where mal='{$mal}' order by ten");
	while($r=mysql_fetch_array($result)){
		$mahs=$r["mahs"];
		$diem=$_POST["$r[mahs]"];
		$sql="insert into diemkt(mamh,mahs,kyhoc,diem,loaidiem,ngay) values('{$mamh}','{$mahs}','{$kyhoc}','{$diem}','{$loaidiem}','{$date}')";	
		mysql_query("$sql") or die("Error!");
	}									
	mysql_close();
	header("Location:themdiemkiemtragv.php?magv=$magv&mal=$mal&mamh=&mamh");											
?>